package org.price.sql.repo.documents.config;

import java.sql.Connection;
import java.sql.PreparedStatement;

import org.apache.log4j.Logger;

public class CreateTablesThread extends SQLThread {

    private static final Logger LOG = Logger.getLogger(CreateTablesThread.class);

    public CreateTablesThread(Connection connection) {
        super(connection);
    }

    @Override
    protected void executeQuery() throws Exception {
        PreparedStatement stm = getConnection().prepareStatement(
                "DROP TABLE Test");

        LOG.info("Drop table: " + stm.executeUpdate());
        stm.close();

        stm = getConnection().prepareStatement(
                "CREATE TABLE Test(id varchar(100) CONSTRAINT Test_PK PRIMARY KEY,"
                        + "title       varchar(1140) NOT NULL)");

        LOG.info("Create table: " + stm.executeUpdate());
        stm.close();
    }

}
